package main

import (
	"flag"
	"fmt"

	"gitee.com/hlwqds/go-my-cache-server/cluster"
	http "gitee.com/hlwqds/go-my-cache-server/http"
	"gitee.com/hlwqds/go-my-cache-server/tcp"

	"gitee.com/hlwqds/go-my-cache-server/cache"
)

func main() {
	typ := flag.String("type", "inmemory", "cache type")
	node := flag.String("node", "127.0.0.1", "node address")
	clus := flag.String("cluster", "", "cluster address")
	ttl := flag.Int("ttl", 30, "cache time to live")
	flag.Parse()
	fmt.Println("type is: ", *typ)
	fmt.Println("ttl is: ", *ttl)
	fmt.Println("node is: ", *node)
	fmt.Println("cluster is: ", *clus)
	cache := cache.New(*typ, *ttl)
	n, err := cluster.New(*node, *clus)
	if err != nil {
		panic(err)
	}
	go tcp.New(cache, n).Listen()
	http.New(cache, n).Listen()
}
